home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / ENTRY.SWG / 0011_Readline Function.pas < prev    next >
Pascal/Delphi Source File  |  1994-05-25  |  2KB  |  55 lines

  1. {
  2. The Readln statement can't really be used here, because this interchange is
  3. taking place in Graphics mode.  I am writing a Graphics application that
  4. does take user input
  5. }
  6. Function KBString:String; {* Gets string from keyboard using Scankey *}
  7.          Var
  8.            bu,X,Inchar:Integer;
  9.            STRBUFF:STRING;
  10.          begin
  11.          STRBUFF := '';
  12.          X:=20;
  13.           Repeat
  14.                Inchar := Scankey;
  15.                IF FK and (Inchar = 60) then
  16.                   Begin
  17.                        Cancel := True;
  18.                        Exit;
  19.                   End;
  20.                setcolor(0);
  21.                setlinestyle (0,0,1);
  22.                Rectangle(15,70,X+5,90);
  23.                setcolor(BLDCLR);
  24.                If Not FK  then outtextxy (x,77,CHR(INCHAR));
  25.                If inchar <> 8 then
  26.                   Begin
  27.                        X := X+ Textwidth(CHR(INCHAR));
  28.                        setcolor(txtclr);
  29.                        Rectangle(15,70,X+5,90);
  30.                   End
  31.                else
  32.                begin
  33.                   setcolor(0);
  34.                   setlinestyle (0,0,1);
  35.                   Rectangle(15,70,X+5,90);
  36.                   x:=x-textwidth(Strbuff[length(strbuff)]);
  37.                   outtextxy(X,77,strbuff[length(strbuff)]);
  38.                   setcolor(txtclr);
  39.                   Rectangle(15,70,x+5,90);
  40.                   Delete(Strbuff,Length(Strbuff),1);
  41.                   setcolor(BLDCLR);
  42.                End;
  43.                If (Not FK) and (Inchar <> 8)  then STRBUFF := STRBUFF +
  44.                                                       CHR(Inchar);
  45.           Until inchar = 13;
  46.          Delete(strBuff,Length(StrBuff),1);
  47.          setcolor(txtclr);
  48.          KBString := STRBUFF;
  49.          End;
  50.  
  51. This code snippet should give you some ideas on getting user input.  BTW
  52. SCANKEY is a function I wrote to read the keyboard.  You should be able to
  53. use READKEY in its place.  This routine also features the ability to edit
  54. with the backspace key.  I hope it helps.
  55.